package Methods;

import SeqList.SeqList;
import TripleTable.TripleTable;
import SpotTable.SpotTable;

public class SearchNear {
    TripleTable path;
    SpotTable spot;

    public SeqList[] SearchNear(String name){//查找与目标景点相邻的景点
        int id = this.spot.turnName2Id(name);
        int j = 0;
        SeqList near = new SeqList(this.path.length());
        for(int i = 0;i <= this.path.length();i++){
            if (this.path.getRow(i) == id){
                near.lengthen(this.path.getCol(i));
                j++;
            }
        }
        /*
        for(int i = 0;i <= this.len;i++){
            if (this.data.getCol(i) == id){
                near.lengthen(this.data.getRow(i));
                j++;
            }
        }
        for(int i = 0;i <= j;i++){
            for (int k = i; k < j; k++) {
                if (near.get(i) == near.get(k)){
                    near.remove(k);
                }
            }
        }
         */
        //由于将三元组表的内存扩大了一倍，现无需此代码
        return (SeqList[]) near.getElements();
    }
}
